package com.slim.daoimpl;

import java.util.List;

import org.appfuse.model.Deliverables;
import org.springframework.stereotype.Repository;

import com.slim.dao.DeliverablesDao;

@Repository
public class DeliverablesDaoImpl extends
		GenericDaoHibernate<Deliverables, Long> implements DeliverablesDao
{

	public DeliverablesDaoImpl() {
		super(Deliverables.class);

	}

	public Deliverables loadDeliverablesByProjectId(Long projectId) {
		
		List DeliverablesList = getHibernateTemplate().find(
				"from Deliverables where projectId=?", projectId);
		if ((DeliverablesList == null) || (DeliverablesList.isEmpty())) {
			try {
				throw new Exception("projectId '" + projectId
						+ "' not found...");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return (Deliverables) DeliverablesList.get(0);
	}

	/*    */
	/*    */
	/*    */

	public Long getDeliverablesId(Long id) {
		// TODO Auto-generated method stub
		return null;
	}

	public Deliverables saveDeliverables(Deliverables deliverables) {
		if (this.log.isDebugEnabled()) {
			this.log.debug("projectId: "
					+ deliverables.getId());
		}
		getHibernateTemplate().save(deliverables);
		getHibernateTemplate().flush();
		return deliverables;
	}
}
